<template>
  <div>
    <van-tabbar
      fixed
      route
      v-model="active"
      @change="handleChange"
    >
      <van-tabbar-item
        v-for="(item, index) in data"
        :to="item.to"
        :icon="item.icon"
        :key="index"
        :info="item.info"
      >
        {{ item.title }}
      </van-tabbar-item>
    </van-tabbar>
  </div>
</template>
<script>
export default {
  name: 'TabBar',
  props: {
    defaultActive: {
      type: Number,
      default: 0
    },
    data: {
      type: Array,
      default: () => {
        return []
      }
    }
  },
  data() {
    return {
      active: this.defaultActive
    }
  },
  methods: {
    handleChange(value) {
      this.$emit('change', value)
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
